Use grouped check buttons.
gboolean use_file = FALSE;
char *content_type = NULL;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_file)))
+ if (gtk_check_button_get_active (GTK_CHECK_BUTTON (radio_file)))
use_file = TRUE;
- else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_content)))
+ else if (gtk_check_button_get_active (GTK_CHECK_BUTTON (radio_content)))
use_file = FALSE;
if (use_file)
g_signal_connect (file_l, "clicked",
G_CALLBACK (button_clicked), NULL);
- radio_file = gtk_radio_button_new_with_label (NULL, "Use GFile");
- radio_content = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_file),
- "Use content type");
+ radio_file = gtk_check_button_new_with_label ("Use GFile");
+ radio_content = gtk_check_button_new_with_label ("Use content type");
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (radio_content), GTK_CHECK_BUTTON (radio_file));
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (radio_file), GTK_CHECK_BUTTON (radio_content));
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (radio_file), TRUE);
gtk_grid_attach (GTK_GRID (grid), radio_file,
0, 1, 1, 1);
PageData *pdata = data;
gboolean complete;
- complete = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
+ complete = gtk_check_button_get_active (GTK_CHECK_BUTTON (check));
gtk_assistant_set_page_complete (pdata->assistant,
pdata->page,
gtk_box_append (GTK_BOX (page), gtk_label_new (text));
gtk_box_append (GTK_BOX (page), check);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), complete);
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (check), complete);
pdata = g_new (PageData, 1);
pdata->assistant = GTK_ASSISTANT (assistant);
GtkWidget *page = data;
gboolean visible;
- visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (check));
+ visible = gtk_check_button_get_active (GTK_CHECK_BUTTON (check));
g_object_set (G_OBJECT (page), "visible", visible, NULL);
}
next = add_completion_test_page (assistant, "More Content", TRUE, TRUE);
check = gtk_check_button_new_with_label ("Next page visible");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE);
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (check), TRUE);
g_signal_connect (G_OBJECT (check), "toggled",
G_CALLBACK (visible_cb), next);
gtk_box_append (GTK_BOX (page), check);
gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), page, "Summary");
gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), page, GTK_ASSISTANT_PAGE_SUMMARY);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (page),
- gtk_assistant_get_page_complete (GTK_ASSISTANT (assistant),
- page));
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (page),
+ gtk_assistant_get_page_complete (GTK_ASSISTANT (assistant),
+ page));
pdata = g_new (PageData, 1);
pdata->assistant = GTK_ASSISTANT (assistant);
if (!assistant)
{
- GtkWidget *page, *button;
+ GtkWidget *page, *button, *group;
assistant = gtk_assistant_new ();
gtk_window_set_default_size (GTK_WINDOW (assistant), 400, 300);
page = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- button = gtk_radio_button_new_with_label (NULL, "branch A");
+ button = gtk_check_button_new_with_label ("branch A");
gtk_box_append (GTK_BOX (page), button);
g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (select_branch), GINT_TO_POINTER ('A'));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
+ group = button;
- button = gtk_radio_button_new_with_label (gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
- "branch B");
+ button = gtk_check_button_new_with_label ("branch B");
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
gtk_box_append (GTK_BOX (page), button);
g_signal_connect (G_OBJECT (button), "toggled", G_CALLBACK (select_branch), GINT_TO_POINTER ('B'));
assistant = (GtkAssistant*) data;
page = gtk_assistant_get_nth_page (assistant, current_page);
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (page)))
+ if (gtk_check_button_get_active (GTK_CHECK_BUTTON (page)))
return 0;
else
return 4;
int i, j;
GtkCssProvider *provider;
gboolean done = FALSE;
+ GtkWidget *group = NULL;
gtk_init ();
gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
gtk_box_append (GTK_BOX (hbox), button);
- button = gtk_radio_button_new_with_label (NULL, "│Xyj,Ö");
+ button = gtk_check_button_new_with_label ("│Xyj,Ö");
if (j == 0)
gtk_widget_set_valign (button, GTK_ALIGN_BASELINE);
gtk_box_append (GTK_BOX (hbox), button);
+ if (group == NULL)
+ {
+ group = button;
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
+ }
+ else
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button),
+ GTK_CHECK_BUTTON (group));
}
set_blank (GtkWidget *button,
GtkEntry *entry)
{
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, NULL);
}
set_icon_name (GtkWidget *button,
GtkEntry *entry)
{
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
gtk_entry_set_icon_from_icon_name (entry, GTK_ENTRY_ICON_SECONDARY, "media-floppy");
}
{
GIcon *icon;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
{
icon = g_themed_icon_new ("gtk-yes");
gtk_entry_set_icon_from_gicon (entry, GTK_ENTRY_ICON_SECONDARY, icon);
{
GdkTexture *texture;
- if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+ if (gtk_check_button_get_active (GTK_CHECK_BUTTON (button)))
{
texture = gdk_texture_new_from_resource ("/org/gtk/libgtk/inspector/logo.png");
gtk_entry_set_icon_from_paintable (entry, GTK_ENTRY_ICON_SECONDARY, GDK_PAINTABLE (texture));
gtk_widget_set_vexpand (GTK_WIDGET (box), TRUE);
gtk_grid_attach (GTK_GRID (grid), box, 0, 5, 3, 1);
- button1 = gtk_radio_button_new_with_label (NULL, "Blank");
+ button1 = gtk_check_button_new_with_label ("Blank");
gtk_widget_set_valign (button1, GTK_ALIGN_START);
g_signal_connect (button1, "toggled", G_CALLBACK (set_blank), entry);
gtk_box_append (GTK_BOX (box), button1);
- button2 = gtk_radio_button_new_with_label (NULL, "Icon Name");
+ button2 = gtk_check_button_new_with_label ("Icon Name");
gtk_widget_set_valign (button2, GTK_ALIGN_START);
- gtk_radio_button_join_group (GTK_RADIO_BUTTON (button2), GTK_RADIO_BUTTON (button1));
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button2), GTK_CHECK_BUTTON (button1));
g_signal_connect (button2, "toggled", G_CALLBACK (set_icon_name), entry);
gtk_box_append (GTK_BOX (box), button2);
- button3 = gtk_radio_button_new_with_label (NULL, "GIcon");
+ button3 = gtk_check_button_new_with_label ("GIcon");
gtk_widget_set_valign (button3, GTK_ALIGN_START);
- gtk_radio_button_join_group (GTK_RADIO_BUTTON (button3), GTK_RADIO_BUTTON (button1));
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button3), GTK_CHECK_BUTTON (button1));
g_signal_connect (button3, "toggled", G_CALLBACK (set_gicon), entry);
gtk_box_append (GTK_BOX (box), button3);
- button4 = gtk_radio_button_new_with_label (NULL, "Texture");
+ button4 = gtk_check_button_new_with_label ("Texture");
gtk_widget_set_valign (button4, GTK_ALIGN_START);
- gtk_radio_button_join_group (GTK_RADIO_BUTTON (button4), GTK_RADIO_BUTTON (button1));
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button4), GTK_CHECK_BUTTON (button1));
g_signal_connect (button4, "toggled", G_CALLBACK (set_texture), entry);
gtk_box_append (GTK_BOX (box), button4);
GtkWidget *hbox;
GtkWidget *label;
GtkWidget *entry;
+ GtkWidget *group;
grid = gtk_grid_new ();
gtk_widget_set_vexpand (grid, TRUE);
- radio_button = gtk_radio_button_new_with_label (NULL, "Red");
+ radio_button = gtk_check_button_new_with_label ("Red");
gtk_widget_set_hexpand (radio_button, TRUE);
gtk_grid_attach (GTK_GRID (grid), radio_button, 0, 0, 1, 1);
+ group = radio_button;
- radio_button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_button), "Green");
+ radio_button = gtk_check_button_new_with_label ("Green");
gtk_widget_set_hexpand (radio_button, TRUE);
gtk_grid_attach (GTK_GRID (grid), radio_button, 0, 1, 1, 1);
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (radio_button), GTK_CHECK_BUTTON (group));
- radio_button = gtk_radio_button_new_with_label_from_widget (GTK_RADIO_BUTTON (radio_button), "Blue"),
+ radio_button = gtk_check_button_new_with_label ("Blue"),
gtk_widget_set_hexpand (radio_button, TRUE);
gtk_grid_attach (GTK_GRID (grid), radio_button, 0, 2, 1, 1);
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (radio_button), GTK_CHECK_BUTTON (group));
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (group), TRUE);
check_button = gtk_check_button_new_with_label ("Sedentary"),
gtk_widget_set_hexpand (check_button, TRUE);
}
static GtkWidget *
-create_widget_grid (GType widget_type)
+create_widget_grid (gboolean group)
{
GtkWidget *grid;
GtkWidget *group_widget = NULL;
}
else
{
- widget = g_object_new (widget_type, NULL);
-
- if (g_type_is_a (widget_type, GTK_TYPE_RADIO_BUTTON))
+ widget = gtk_check_button_new ();
+ if (group)
{
if (!group_widget)
group_widget = widget;
else
- g_object_set (widget, "group", group_widget, NULL);
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (widget), GTK_CHECK_BUTTON (group_widget));
}
}
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
gtk_box_append (GTK_BOX (box1), separator);
- table = create_widget_grid (GTK_TYPE_CHECK_BUTTON);
+ table = create_widget_grid (FALSE);
gtk_widget_set_vexpand (table, TRUE);
gtk_box_append (GTK_BOX (box2), table);
}
GtkWidget *button;
GtkWidget *separator;
GtkWidget *table;
+ GtkWidget *group;
if (!window)
{
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_box_append (GTK_BOX (box1), box2);
- button = gtk_radio_button_new_with_label (NULL, "button1");
+ button = gtk_check_button_new_with_label ("button1");
gtk_box_append (GTK_BOX (box2), button);
+ group = button;
- button = gtk_radio_button_new_with_label (
- gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
- "button2");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ button = gtk_check_button_new_with_label ("button2");
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
gtk_box_append (GTK_BOX (box2), button);
- button = gtk_radio_button_new_with_label (
- gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
- "button3");
+ button = gtk_check_button_new_with_label ("button3");
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
gtk_box_append (GTK_BOX (box2), button);
- button = gtk_radio_button_new_with_label (
- gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
- "inconsistent");
+ button = gtk_check_button_new_with_label ("inconsistent");
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
gtk_check_button_set_inconsistent (GTK_CHECK_BUTTON (button), TRUE);
gtk_box_append (GTK_BOX (box2), button);
box2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
gtk_box_append (GTK_BOX (box1), box2);
- button = gtk_radio_button_new_with_label (NULL, "button4");
+ button = gtk_check_button_new_with_label ("button4");
gtk_box_append (GTK_BOX (box2), button);
+ group = button;
- button = gtk_radio_button_new_with_label (
- gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
- "button5");
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
+ button = gtk_check_button_new_with_label ("button5");
+ gtk_check_button_set_active (GTK_CHECK_BUTTON (button), TRUE);
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
gtk_box_append (GTK_BOX (box2), button);
- button = gtk_radio_button_new_with_label (
- gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
- "button6");
+ button = gtk_check_button_new_with_label ("button6");
+ gtk_check_button_set_group (GTK_CHECK_BUTTON (button), GTK_CHECK_BUTTON (group));
gtk_box_append (GTK_BOX (box2), button);
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
gtk_box_append (GTK_BOX (box1), separator);
- table = create_widget_grid (GTK_TYPE_RADIO_BUTTON);
+ table = create_widget_grid (TRUE);
gtk_box_append (GTK_BOX (box1), table);
}